package com.airsystem.pos.bengkel.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 * @author Fanny Irawan Sutawanir (fannyirawans@gmail.com)
 */

@Entity
@Table(name = "tbl_pesan_sparepart")
public class PesanSparepart implements Serializable {

	@Transient
	public static final String ALIAS = "pesan_sparepart";

	@Id
	@GeneratedValue
	@Column(unique = true, nullable = false)
	private Long id;

	@Temporal(TemporalType.DATE)
	private Date tanggal;

	@OneToMany(mappedBy = "pesan_sparepart", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, orphanRemoval = true)
	private Set<DetailPesanSparepart> detail_pesan_sparepart = new HashSet<DetailPesanSparepart>(0);

	/**
	 * Used on Sparepart Order <b>update process</b>.
	 * <br>
	 * Contains new/edited {@link DetailPesanSparepart} record.
	 */
	@Transient
	private Set<DetailPesanSparepart> new_detail_pesan_sparepart;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getTanggal() {
		return tanggal;
	}

	public void setTanggal(Date tanggal) {
		this.tanggal = tanggal;
	}

	public Set<DetailPesanSparepart> getDetail_pesan_sparepart() {
		return detail_pesan_sparepart;
	}

	public void setDetail_pesan_sparepart(Set<DetailPesanSparepart> detail_pesan_sparepart) {
		this.detail_pesan_sparepart = detail_pesan_sparepart;
	}

	public void addDetail_pesan_sparepart(DetailPesanSparepart record) {
		this.detail_pesan_sparepart.add(record);
	}

	public Set<DetailPesanSparepart> getNew_detail_pesan_sparepart() {
		return new_detail_pesan_sparepart;
	}

	public void setNew_detail_pesan_sparepart(Set<DetailPesanSparepart> new_detail_pesan_sparepart) {
		this.new_detail_pesan_sparepart = new_detail_pesan_sparepart;
	}
}